<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Vue app</title>
    <script src="vite-project/node_modules/vue/dist/vue.global.js"></script>
    <script>
        function isPrime(n) {
            const resultA = document.getElementById('result');
            var isPrime = true;
            if (n <= 1) {
                isPrime = false;
            } else {
                for (var i = 2; i <= Math.sqrt(n); i++) {
                    if (n % i === 0) {
                        isPrime = false;
                        break;
                    }
                }
            }
            if (isPrime) {
                resultA.innerHTML = n + "是质数";
            } else {
                resultA.innerHTML = n + "不是质数";
            }

        }

        function checkPrime() {
            const input = document.getElementById('numberInput');
            const n = Number(input.value);
            isPrime(n);
        }
    </script>
</head>

<body>
    <h1>判断质数</h1>
    <input type="number" id="numberInput" placeholder="请输入数字">
    <button onclick="checkPrime()">判断是否为质数</button>
    <div id="result"></div>
</body>

</html>